home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1987 / 06 / bbs.l6 < prev    next >
Text File  |  1987-05-05  |  3KB  |  132 lines

  1. Listing Six
  2.  
  3. pmail
  4.  
  5.  
  6.  
  7. 1    USERS=/u/bbs/rbin/user.file
  8. 2    echo 'who am i | cut -f1 -d" " ' 'date | cut -c1-16' "pmail" >>/u/bbs/log.file
  9.  
  10.     # display pmail instructions
  11.  
  12. 3    echo
  13. 4    echo"  ************** Private Mail ***************"
  14. 5    echo
  15. 6    echo        Commands:
  16. 7    echo        s - send mail to another user
  17. 8    echo        r - read mail sent to you
  18. 9    echo        l - list the users by user id and name
  19. 10    echo        x - exit the private mail system
  20. 11    echo
  21.  
  22.     # accept the first pmail command
  23.  
  24. 12    echo "Command: \c"
  25. 13    read choice
  26.  
  27.     # loop until the user wants to quit
  28.  
  29. 14    while [ "$choice" != x -o "$choice" != X ]
  30. 15    do
  31. 16        echo
  32. 17        case $choice in
  33. 18            [Ss])
  34.  
  35.     # send private mail
  36.     # print instructions
  37.  
  38. 19                echo "WARNING: To successfully send mail observe these rules:"
  39. 20                echo
  40. 21                echo "   1. If you wish to erase a character, use the backspace key."
  41. 22                echo "DO NOT, DO NOT use the delete key."
  42. 23                echo "   2. Type a carriage return at the end of each line on the"
  43. 24                echo "screen.  Lines should be no more than 80 characters."
  44. 25                echo "   3. Do not use the following characters in your message (they"
  45. 26                echo "have special meaning to the system): @ and #"
  46. 27                echo
  47. 28                echo "Press RETURN to begin sending your message: \c"
  48. 29                read dummy
  49. 30                echo
  50.  
  51.     # collect user id of recipient
  52.  
  53. 31                echo "To whom (user id): \c"
  54. 32                read to
  55.  
  56.     # verify that recipient entered is a valid user id
  57.  
  58. 33                TPERS='grep $to $USERS | wc -c'
  59. 34                if [ "$TPERS" -eq 0 ]
  60. 35                then
  61.  
  62.     # user id is invalid
  63.  
  64. 36                    echo
  65. 37                    echo "Sorry, that user id doesn't exist."
  66. 38                    echo "List them with the l command."
  67. 39                else
  68.  
  69.     # send mail
  70.  
  71. 40                    echo
  72. 41                    echo "Start typing your message.  Type a period on a new"
  73. 42                    echo "line to send the message."
  74. 43                    echo
  75. 44                    mail $to
  76. 45                fi
  77.  
  78.     # collect next option
  79.  
  80. 46                echo
  81. 47                echo "Command (x to exit): \c"
  82. 48                read choice
  83. 49                continue;;
  84. 50            [Rr])
  85.  
  86.     # read private mail
  87.     # print instructions
  88.  
  89. 51                echo "After each message you will receive a ╒?╒ prompt."
  90. 52                echo "Type ╒d╒ to delete the message, <cr> to leave it in"
  91. 53                echo "your mailbox, or ╒q╒ to stop reading mail."
  92. 54                echo
  93.  
  94.     # real the mail
  95. 55                mail
  96. 56                echo
  97.  
  98.     # collect the next command
  99.  
  100. 57                echo "Command (x to exit): \c"
  101. 58                read choice
  102. 59                continue;;
  103. 60            [Ll])
  104.  
  105.     # display a list of user names and associated user id's
  106.  
  107. 61                echo
  108. 62                more $USERS
  109. 63                echo
  110.  
  111.     # collect the next command
  112.  
  113. 64                echo "Command (x to exit): \c"
  114. 65                read choice
  115. 66                continue;;
  116. 67            *)
  117.  
  118.     # if an unrecognized command was entered, prompt for another one
  119.  
  120. 68                echo "Command (x to exit): \c"
  121. 69                read choice
  122. 70                continue;;
  123. 71        esac
  124. 72    done
  125. 73    echo
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.